package vip.xiaonuo.smzq.modular.hisi.service.impl;

import cn.hutool.core.bean.BeanUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.springframework.transaction.annotation.Transactional;
import vip.xiaonuo.smzq.core.utils.TransFormUtil;
import vip.xiaonuo.smzq.modular.dictionary.entity.Cb01Zh;
import vip.xiaonuo.smzq.modular.dictionary.entity.Cb06Kc;
import vip.xiaonuo.smzq.modular.dictionary.entity.Cb08Xzqh;
import vip.xiaonuo.smzq.modular.dictionary.entity.Cb13Zycllx;
import vip.xiaonuo.smzq.modular.dictionary.mapper.Cb01ZhMapper;
import vip.xiaonuo.smzq.modular.dictionary.mapper.Cb06KcMapper;
import vip.xiaonuo.smzq.modular.dictionary.mapper.Cb08XzqhMapper;
import vip.xiaonuo.smzq.modular.dictionary.mapper.Cb13ZycllxMapper;
import vip.xiaonuo.smzq.modular.hisi.entity.KsZyclhz;
import vip.xiaonuo.smzq.modular.hisi.entity.Kshz;
import vip.xiaonuo.smzq.modular.hisi.entity.param.TbkstjParam;
import vip.xiaonuo.smzq.modular.hisi.entity.vo.*;
import vip.xiaonuo.smzq.modular.hisi.mapper.KsZyclhzMapper;
import vip.xiaonuo.smzq.modular.hisi.mapper.KshzMapper;
import vip.xiaonuo.smzq.modular.hisi.service.IHisiKsService;
import vip.xiaonuo.smzq.modular.hisi.service.IKsZyclhzService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import vip.xiaonuo.common.page.CommonPageRequest;
import vip.xiaonuo.smzq.modular.kcl.entity.*;
import vip.xiaonuo.smzq.modular.kcl.mapper.*;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.UUID;
import java.util.stream.Collectors;

/**
 * 矿山资源储量汇总 服务实现类
 *
 * @author sqq
 * @since 2024-07-04
 */
@Service
public class KsZyclhzServiceImpl extends ServiceImpl<KsZyclhzMapper, KsZyclhz> implements IKsZyclhzService {

    @Resource
    private KsZyclhzMapper ksZyclhzMapper;

    //矿山信息
    @Resource
    private KsMapper ksMapper;

    //矿山经济
    @Resource
    private KsjjMapper ksjjMapper;

    //资源储量信息
    @Resource
    private ZyclMapper zyclMapper;

    //资源储量类型
    @Resource
    private Cb13ZycllxMapper cb13ZycllxMapper;

    //报告
    @Resource
    private BgMapper bgMapper;

    //坐标
    @Resource
    private ZbMapper zbMapper;

    //字典综合表1
    @Resource
    private Cb01ZhMapper cb01ZhMapper;

    //矿山综合数据
    @Resource
    private KshzMapper kshzMapper;

    //矿产
    @Resource
    private Cb06KcMapper cb06KcMapper;
    //行政区划
    @Resource
    private Cb08XzqhMapper cb08XzqhMapper;

    //坐标相关工具类
    @Resource
    TransFormUtil transFormUtil;

    @Override
    public Page<KsZyclhz> page(KsZyclhz ksZyclhz) {
        QueryWrapper<KsZyclhz> queryWrapper = new QueryWrapper<>();
        return this.page(CommonPageRequest.defaultPage(), queryWrapper);
    }

    /**
     * 同步矿山资源储量汇总
     *
     * @param tbkstjParam
     * @return void
     * @Author sqq
     * @Date 2024/7/4 16:04
     */
    @Transactional
    @Override
    public void synchronizingKsData(TbkstjParam tbkstjParam) {
        //查询资源储量类型
        List<Cb13Zycllx> cb13List = cb13ZycllxMapper.selectList(new QueryWrapper<>());
        //行政区划
        String xzqh = "";
        if (tbkstjParam.getXzqbh() != null) {
            xzqh = tbkstjParam.getXzqbh().replaceAll("0+$", "");
        } else {
            xzqh = "13";
        }
        LambdaQueryWrapper<Cb01Zh> queryWrapperZh = new LambdaQueryWrapper<>();
        queryWrapperZh.ne(Cb01Zh::getBnm, 0);
        queryWrapperZh.eq(Cb01Zh::getBh, 71);
        List<Cb01Zh> sbbsList = cb01ZhMapper.selectList(queryWrapperZh);
        //整体查询矿山基本单元相关特点信息
        List<CxtjgjzdVo> cxtjgjzdVoList = ksZyclhzMapper.getCxtjgjzd(tbkstjParam.getNd());


        //查询有多少矿山信息需要统计
        List<KsQueryCriteria> ksQueryCriteriaList = ksZyclhzMapper.synchronizingKsData(tbkstjParam.getNd(), xzqh);
        //通过循环去查询计算数据
        for (KsQueryCriteria ksQueryCriteria : ksQueryCriteriaList) {
            //登记分类编号
            Integer djflbh = ksQueryCriteria.getDjflbh();
            //矿区编号
            String kqbh = ksQueryCriteria.getKqbh();
            //年度
            Integer nd = ksQueryCriteria.getNd();
            //查询矿山详情信息
            LambdaQueryWrapper<Ks> queryWrapper = new LambdaQueryWrapper<>();
            queryWrapper.eq(Ks::getKqbh, kqbh);
            queryWrapper.eq(Ks::getDjflbh, djflbh);
            queryWrapper.eq(Ks::getNd, nd);
            queryWrapper.last("limit 1");
            Ks ks = ksMapper.selectOne(queryWrapper);
            //查询矿山资源储量汇总
            List<KsZyclVo> ksZyclVoList = queryKsZyclhz(ksQueryCriteria, cb13List);

            if (ksZyclVoList.size() > 0) {
                boolean insert = insertZycl(ksZyclVoList, ks, sbbsList, cxtjgjzdVoList);
                if (insert) {
                    System.out.println("年度：" + ks.getNd() + "---矿区编号：" + ks.getKqbh() + "---登记分类编号:" + ks.getDjflbh() + "---资源储量汇总数据同步成功");
                } else {
                    System.out.println("年度：" + ks.getNd() + "---矿区编号：" + ks.getKqbh() + "---登记分类编号:" + ks.getDjflbh() + "---资源储量汇总数据同步失败");
                }
            }


        }
    }

    /**
     * 同步矿山资源储量汇总多年度
     *
     * @param ndStr
     * @return void
     * @Author sqq
     * @Date 2024/7/4 16:04
     */
    @Transactional
    @Override
    public void synchronizingKsDataNd(String ndStr) {
        List<Integer> integerList = Arrays.stream(ndStr.split(","))
                .map(Integer::parseInt)
                .collect(Collectors.toList());

        for (Integer nd : integerList) {
            //先根据年度将矿山综合，矿山资源储量数据删除
            kshzMapper.delete(new LambdaQueryWrapper<Kshz>().eq(Kshz::getNd, nd));
            ksZyclhzMapper.delete(new LambdaQueryWrapper<KsZyclhz>().eq(KsZyclhz::getNd, nd));
            TbkstjParam tbkstjParam = new TbkstjParam();
            tbkstjParam.setNd(nd);
            synchronizingKsData(tbkstjParam);
        }


    }

    /**
     * 查询矿山资源储量汇总
     *
     * @param ksQueryCriteria ks
     * @return List<KsZyclVo>
     * @Author sqq
     * @Date 2024/7/4 16:04
     */

    public List<KsZyclVo> queryKsZyclhz(KsQueryCriteria ksQueryCriteria, List<Cb13Zycllx> cb13List) {
        List<KsZyclVo> ksZyclVoList = new ArrayList<>();
        //登记分类编号
        Integer djflbh = ksQueryCriteria.getDjflbh();
        //矿区编号
        String kqbh = ksQueryCriteria.getKqbh();
        //年度
        Integer nd = ksQueryCriteria.getNd();
        //矿种代码
        Integer kcdm = ksQueryCriteria.getKcdm();
        //统计对象
        Integer tjdx = ksQueryCriteria.getTjdx();

        //查询所有资源储量数据
        LambdaQueryWrapper<Zycl> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(Zycl::getKqbh, kqbh);
        queryWrapper.eq(Zycl::getDjflbh, djflbh);
        queryWrapper.eq(Zycl::getNd, nd);
        queryWrapper.eq(Zycl::getKcdm, kcdm);
        queryWrapper.eq(Zycl::getTjdx, tjdx);
        List<Zycl> zyclList = zyclMapper.selectList(queryWrapper);

        //过滤资源储量类型
        for (Cb13Zycllx cb13Zycllx : cb13List) {
            List<Zycl> zyclNewList = new ArrayList<>();
            for (Zycl zycl : zyclList) {
                if (cb13Zycllx.getDm().equals(zycl.getZycllx())) {
                    zyclNewList.add(zycl);
                }
            }
            //计算所有资源储量类型的值
            if (zyclNewList.size() > 0) {
                KsZyclVo ksZyclVo = calculateZycl(zyclNewList);
                if (ksZyclVo != null) {
                    ksZyclVoList.add(ksZyclVo);
                }
            }


        }
        return ksZyclVoList;
    }

    /**
     * 计算所有资源储量类型的值
     *
     * @param zyclNewList zyclNewList
     * @Author sqq
     */

    public KsZyclVo calculateZycl(List<Zycl> zyclNewList) {
        KsZyclVo ksZyclVo = new KsZyclVo();
        //同步资源储量基本信息
        Zycl zyclBasic = zyclNewList.get(0);
        BeanUtil.copyProperties(zyclBasic, ksZyclVo);

        //年初保有金属量
        double ncbyJsl = 0.0;
        //年初累计金属量
        double ncljJsl = 0.0;
        //开采量 金属量
        double kclJsl = 0;
        //损失量 金属量
        double sslJsl = 0;
        //勘察增减（±） 金属量
        double kczjJsl = 0;
        //重算增减（±）金属量
        double cszjJsl = 0;
        //年末保有 金属量
        double nmbyJsl = 0;
        //累计查明 金属量
        double ljcmJsl = 0;
        //审批压覆量 金属量
        double spyflJsl = 0;
        //其他 金属量
        double otherDataJsl = 0;


        //年初保有矿石量
        double ncbyKsl = 0.0;
        //年初累计矿石量
        double ncljKsl = 0.0;
        //开采量 矿石量
        double kclKsl = 0;
        //损失量 矿石量
        double sslKsl = 0;
        //勘察增减（±） 矿石量
        double kczjKsl = 0;
        //重算增减（±）矿石量
        double cszjKsl = 0;
        //年末保有 矿石量
        double nmbyKsl = 0;
        //累计查明 矿石量
        double ljcmKsl = 0;
        //审批压覆量 矿石量
        double spyflKsl = 0;
        //其他 矿石量
        double otherDataKsl = 0;


        for (Zycl zycl : zyclNewList) {
            switch (zycl.getZycllb()) {
                case 19001://年末保有
                    nmbyJsl += zycl.getJsl();
                    nmbyKsl += zycl.getKsl();
                    break;
                case 19002://累计查明
                    ljcmKsl += zycl.getKsl();
                    ljcmJsl += zycl.getJsl();
                    break;
                case 19004://开采量
                    kclJsl += zycl.getJsl();
                    kclKsl += zycl.getKsl();
                    break;
                case 19005://损失量
                    sslJsl += zycl.getJsl();
                    sslKsl += zycl.getKsl();
                    break;
                case 19006://勘察增减
                    kczjJsl += zycl.getJsl();
                    kczjKsl += zycl.getKsl();
                    break;
                case 19008://重算增减
                    cszjJsl += zycl.getJsl();
                    cszjKsl += zycl.getKsl();
                    break;
                case 19009://审批压覆量
                    spyflJsl += zycl.getJsl();
                    spyflKsl += zycl.getKsl();
                    break;
                case 19007://其他
                    otherDataJsl += zycl.getJsl();
                    otherDataKsl += zycl.getKsl();
                    break;
                case 19012://年初保有
                    ncbyJsl += zycl.getJsl();
                    ncbyKsl += zycl.getKsl();

                    break;
                case 19013://年初累计
                    ncljJsl += zycl.getJsl();
                    ncljKsl += zycl.getKsl();
                    break;
            }
        }

        ksZyclVo.setNmbyjsl(nmbyJsl);
        ksZyclVo.setNmbyksl(nmbyKsl);

        ksZyclVo.setKcljsl(kclJsl);
        ksZyclVo.setKclksl(kclKsl);

        ksZyclVo.setSsljsl(sslJsl);
        ksZyclVo.setSslksl(sslKsl);

        ksZyclVo.setKczjjsl(kczjJsl);
        ksZyclVo.setKczjksl(kczjKsl);

        ksZyclVo.setCszjjsl(cszjJsl);
        ksZyclVo.setCszjksl(cszjKsl);

        ksZyclVo.setSpyfjsl(spyflJsl);
        ksZyclVo.setSpyfksl(spyflKsl);

        ksZyclVo.setOtherdatajsl(otherDataJsl);
        ksZyclVo.setOtherdataksl(otherDataKsl);

        ksZyclVo.setLjcmjsl(ljcmJsl);
        ksZyclVo.setLjcmksl(ljcmKsl);

        ksZyclVo.setNcljjsl(ncljJsl);
        ksZyclVo.setNcljksl(ncljKsl);

        ksZyclVo.setNcbyjsl(ncbyJsl);
        ksZyclVo.setNcbyksl(ncbyKsl);

        QueryWrapper<Cb06Kc> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("kcdm", zyclBasic.getKcdm());
        queryWrapper.eq("tjdx", zyclBasic.getTjdx());
        queryWrapper.last("limit 1");
        Cb06Kc cb06Kc = cb06KcMapper.selectOne(queryWrapper);

        if (cb06Kc.getJsldw() != null) {
            ksZyclVo.setJsldw(cb06Kc.getJsldw());
        }
        if (cb06Kc.getJsdxmc() != null) {
            ksZyclVo.setJsdxmc(cb06Kc.getJsdxmc());
        }
        ksZyclVo.setKcmc(cb06Kc.getKcmc());
        ksZyclVo.setKsldw(cb06Kc.getKsldw());

        return ksZyclVo;
    }

    /**
     * 整理数据入库
     *
     * @param ksZyclVoList ksZyclVoList Ks ks
     * @Author sqq
     */

    public boolean insertZycl(List<KsZyclVo> ksZyclVoList, Ks ks, List<Cb01Zh> sbbsList, List<CxtjgjzdVo> cxtjgjzdVoList) {
        List<KsZyclhz> ksZyclhzList = new ArrayList<>();
        String matchstr = "_";
        if (ks.getKqbh() != null) {
            matchstr += ks.getKqbh() + "_";
        }

        if (ks.getKsbh() != null) {
            matchstr += ks.getKsbh() + "_";
        }
        if (ks.getDjflbh() != null) {
            matchstr += ks.getDjflbh() + "_";
        }
        boolean flag = false;
        //循环计算
        for (KsZyclVo ksZyclVo : ksZyclVoList) {
            KsZyclhz ksZyclhz = new KsZyclhz();
            BeanUtil.copyProperties(ksZyclVo, ksZyclhz);
            ksZyclhzList.add(ksZyclhz);
        }


        Kshz kshz = new Kshz();
        KsZyclVo ksZyclVo = ksZyclVoList.get(0);

        BeanUtil.copyProperties(ks, kshz);
        BeanUtil.copyProperties(ksZyclVo, kshz);

        if (ks.getKqbh() != null) {
            LambdaQueryWrapper<Ks> ksqueryWrapper = new LambdaQueryWrapper<>();
            if (ks.getNd() != null){
                ksqueryWrapper.eq(Ks::getNd, kshz.getNd());
            }
            ksqueryWrapper.eq(Ks::getKqbh, kshz.getKqbh());
            ksqueryWrapper.eq(Ks::getDjflbh, 1000);
            ksqueryWrapper.last("limit 1");
            Ks kq = ksMapper.selectOne(ksqueryWrapper);
            if (kq != null){
                if (kq.getKsmc()!=null) {
                    kshz.setKqmc(kq.getKsmc());
                }
            }

        }

        kshz.setKcdm(ksZyclVo.getKcdm());

        if (ksZyclVo.getKcdm() != null) {
            matchstr += ksZyclVo.getKcdm() + "_";
        }
        if (ksZyclVo.getTjdx() != null) {
            matchstr += ksZyclVo.getTjdx() + "_";
        }

        CxtjgjzdVo cxtjgjzdVo = new CxtjgjzdVo();

        for (CxtjgjzdVo cxtjgjzdVoMatch : cxtjgjzdVoList) {
            String cxrStr = "_";
            if (cxtjgjzdVoMatch.getKqbh() != null) {
                cxrStr += cxtjgjzdVoMatch.getKqbh() + "_";
            }
            if (cxtjgjzdVoMatch.getKsbh() != null) {
                cxrStr += cxtjgjzdVoMatch.getKsbh() + "_";
            }
            if (cxtjgjzdVoMatch.getDjflbh() != null) {
                cxrStr += cxtjgjzdVoMatch.getDjflbh() + "_";
            }
            if (cxtjgjzdVoMatch.getKcdm() != null) {
                cxrStr += cxtjgjzdVoMatch.getKcdm() + "_";
            }
            if (cxtjgjzdVoMatch.getTjdx() != null) {
                cxrStr += cxtjgjzdVoMatch.getTjdx() + "_";
            }

            if (cxrStr.equals(matchstr)) {
                cxtjgjzdVo = cxtjgjzdVoMatch;
                break;
            }
        }
//添加规模
        if (cxtjgjzdVo.getGm() != null && !cxtjgjzdVo.getGm().equals("-1")) {
            LambdaQueryWrapper<Cb01Zh> queryWrapperzh = new LambdaQueryWrapper<>();
            queryWrapperzh.eq(Cb01Zh::getBnm, (3-Integer.parseInt(cxtjgjzdVo.getGm())));
            queryWrapperzh.eq(Cb01Zh::getBh, 13);
            Cb01Zh gm = cb01ZhMapper.selectOne(queryWrapperzh);
            kshz.setGm(gm.getMc());
        }
//矿山规模
        if (cxtjgjzdVo.getKsgmm() != null && cxtjgjzdVo.getKsgmm() != -1) {
            kshz.setKsgmm(cxtjgjzdVo.getKsgmm());
        }
        if (cxtjgjzdVo.getKsgm() != null) {
            kshz.setKsgm(cxtjgjzdVo.getKsgm());
        }
//勘察阶段
        if (cxtjgjzdVo.getKcjd() != null && cxtjgjzdVo.getKcjd() != -1) {
            kshz.setKcjdm(cxtjgjzdVo.getKcjd() + 101);
            LambdaQueryWrapper<Cb01Zh> queryWrapperkcjd = new LambdaQueryWrapper<>();
            queryWrapperkcjd.eq(Cb01Zh::getBnm, (cxtjgjzdVo.getKcjd() + 101));
            queryWrapperkcjd.eq(Cb01Zh::getBh, 15);
            Cb01Zh kcjd = cb01ZhMapper.selectOne(queryWrapperkcjd);
            kshz.setKcjdmc(kcjd.getMc());
        }
//开采情况
        if (cxtjgjzdVo.getKcqk() != null && cxtjgjzdVo.getKcqk() != -1) {
            kshz.setKcqk(cxtjgjzdVo.getKcqk());
        }
//是否利用
        if (cxtjgjzdVo.getSfly() != null && cxtjgjzdVo.getSfly() != -1) {
            kshz.setSfly(cxtjgjzdVo.getSfly());
        }
//生产状态
        if (cxtjgjzdVo.getSczt() != null && cxtjgjzdVo.getScztm() != -1) {
            kshz.setSczt(cxtjgjzdVo.getSczt());
            if (cxtjgjzdVo.getScztm() != null) {
                kshz.setScztm(cxtjgjzdVo.getScztm());
            }
        }

        //添加是否出界
        boolean isInPolygon = getsfcj(ks);
        if (isInPolygon) {
            kshz.setSfcj(0);
        } else {
            kshz.setSfcj(1);
        }

        //矿产组合
        LambdaQueryWrapper<Cb01Zh> queryWrapperZh = new LambdaQueryWrapper<>();
        queryWrapperZh.eq(Cb01Zh::getBnm, cxtjgjzdVo.getKczhm());
        queryWrapperZh.eq(Cb01Zh::getBh, 16);
        Cb01Zh cb01Zh = cb01ZhMapper.selectOne(queryWrapperZh);
        if (cb01Zh != null) {
            kshz.setKczh(cb01Zh.getMc());
            kshz.setKczhm(cb01Zh.getDm());
        }

        //添加行政区划市级代码
        if (ks.getXzqdm() != null) {
            LambdaQueryWrapper<Cb08Xzqh> queryWrapperXzqh = new LambdaQueryWrapper<>();
            queryWrapperXzqh.eq(Cb08Xzqh::getDm, ks.getXzqdm());
            Cb08Xzqh cb08Xzqh = cb08XzqhMapper.selectOne(queryWrapperXzqh);
            if (cb08Xzqh != null){
                kshz.setFxzqdm(String.valueOf(cb08Xzqh.getFdm()));
            }
        }
        //上表标识

        if (ks.getSbbs() != null) {
            for (Cb01Zh sbbs : sbbsList) {
                if (sbbs.getBnm().equals(ks.getSbbs())) {
                    kshz.setSbbs(sbbs.getMc());
                    kshz.setSbbsm(sbbs.getBnm());
                }
            }

        }

        //矿业权类型（1，无矿权，2采矿权，3探矿权）
        int djflbhm=0;

        if (ks.getDjflbh()!=null){
            djflbhm=ks.getDjflbh()/1000;
            if (djflbhm==2){
                kshz.setKqlx(2);
            }else{
                if (ks.getKqbh() != null){
                    LambdaQueryWrapper<Ks> queryWrapperKs = new LambdaQueryWrapper<>();
                    queryWrapperKs.eq(Ks::getKqbh, ks.getKqbh());
                    queryWrapperKs.eq(Ks::getDjflbh, 1000);
                    queryWrapperKs.eq(Ks::getNd, ks.getNd());
                    queryWrapperKs.last("limit 1");
                    Ks kq = ksMapper.selectOne(queryWrapperKs);
                    if(kq!=null){
                        if ((kq.getKyqr() != null && !kq.getKyqr().equals("")) || (kq.getXkzh() != null && !kq.getXkzh().equals(""))) {
                            kshz.setKqlx(3);
                        }else{
                            kshz.setKqlx(1);
                        }
                    }

                }else if(ks.getKsbh()!=null&&!ks.getKsbh().equals("")){
                    LambdaQueryWrapper<Ks> queryWrapperKs = new LambdaQueryWrapper<>();
                    queryWrapperKs.eq(Ks::getKsbh, ks.getKsbh());
                    queryWrapperKs.eq(Ks::getNd, ks.getNd());
                    queryWrapperKs.last("limit 1");
                    Ks kq = ksMapper.selectOne(queryWrapperKs);
                    if(kq!=null){
                        if ((kq.getKyqr() != null && !kq.getKyqr().equals("")) || (kq.getXkzh() != null && !kq.getXkzh().equals(""))) {
                            kshz.setKqlx(3);
                        }else{
                            kshz.setKqlx(1);
                        }
                    }
                }
            }
        }else{
            LambdaQueryWrapper<Ks> queryWrapperKs = new LambdaQueryWrapper<>();
            queryWrapperKs.eq(Ks::getKsbh, ks.getKsbh());
            queryWrapperKs.eq(Ks::getNd, ks.getNd());
            queryWrapperKs.last("limit 1");
            Ks kq = ksMapper.selectOne(queryWrapperKs);
            if(kq!=null){
                if ((kq.getKyqr() != null && !kq.getKyqr().equals("")) || (kq.getXkzh() != null && !kq.getXkzh().equals(""))) {
                    kshz.setKqlx(3);
                }else{
                    kshz.setKqlx(1);
                }
            }
        }


        try {
//            //添加数据
            kshz.setPkid(UUID.randomUUID().toString());
            kshzMapper.insert(kshz);
            this.saveBatch(ksZyclhzList);
            flag = true;
        } catch (Exception e) {
            e.printStackTrace();
        }


        return flag;
    }

    /**
     * 获取中心点坐标是否出界
     *
     * @param ks 矿山信息
     */
    public Boolean getsfcj(Ks ks) {
        try {
            if (ks != null) {
                QueryWrapper<Zb> queryWrapperZb = new QueryWrapper<>();
                queryWrapperZb.eq("kqbh", ks.getKqbh()).eq("djflbh", ks.getDjflbh()).eq("nd", ks.getNd());
                queryWrapperZb.last("LIMIT 1");
                Zb zb = zbMapper.selectOne(queryWrapperZb);
                if (zb != null && zb.getKqzb() != null) {
                    System.out.println("坐标范围：" + zb.getKqzb());
                    return transFormUtil.isPointInPolygon(ks.getZxdxzb(), ks.getZxdyzb(), zb.getKqzb());
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
        }

        return false;
    }
}
